
//获取设备信息
function getDeviceInfo() {

    alert("设备的系统版本:" + device.version + "\n" + "设备的平台:" + device.platform +"\n" + "设备的型号" + device.model + "\n" + "cordova版本为：" + device.cordova + "\n" + "设备的uuid:" + device.uuid);

}

//调用相机拍照

function takePicture() {

    navigator.camera.getPicture(onSuccess, onFail, {
        quality: 50,
        destinationType: Camera.DestinationType.DATA_URL
    });

    function onSuccess(imageData) {
        var image = document.getElementById('imageShow');
       image.src = "data:image/jpeg;base64," + imageData;

    }

    function onFail(message) {
        alert('Failed because: ' + message);
    }

}


//获取网络状况

function getNetInfo() {

    var networkState = navigator.connection.type;
    var states = {};

    states[Connection.UNKNOWN]  = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]     = 'WiFi connection';
    states[Connection.CELL_2G]  = 'Cell 2G connection';
    states[Connection.CELL_3G]  = 'Cell 3G connection';
    states[Connection.CELL_4G]  = 'Cell 4G connection';
    states[Connection.CELL]     = 'Cell generic connection';
    states[Connection.NONE]     = 'No network connection';

    alert('Connection type: ' + states[networkState]);
}


//获取位置信息

function getLocationInfo() {


    var onSuccess = function(position) {
        alert('Latitude: '          + position.coords.latitude          + '\n' +
            'Longitude: '         + position.coords.longitude         + '\n' +
            'Altitude: '          + position.coords.altitude          + '\n' +
            'Accuracy: '          + position.coords.accuracy          + '\n' +
            'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
            'Heading: '           + position.coords.heading           + '\n' +
            'Speed: '             + position.coords.speed             + '\n' +
            'Timestamp: '         + position.timestamp                + '\n');
    };

    function onError(error) {
        alert('code: '    + error.code    + '\n' +
            'message: ' + error.message + '\n');
    }

    navigator.geolocation.getCurrentPosition(onSuccess, onError);
}

//扫描二维码

function scanQRCode() {

    function alertSuccess(mess){

        alert("扫描结果是" + mess);

    }

    function alertFail(error){


        alert("调用失败");
    }



    cordova.exec(alertSuccess,alertFail,"HGQRCode","startScan",["Hey,I'm JS!"]);
}